package com.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.entity.SysUser;
import com.entity.SysUserInfo;
import com.service.SysUserInfoService;
import com.service.SysUserService;

@Controller
public class Sys_userController {
    
	@Autowired
	private SysUserService sysUserService;
	
	@Autowired
	private SysUserInfoService sysUserInfoService;
	
	
	@RequestMapping("addUser.s")
	public String addUser(SysUser sysUser,SysUserInfo sysUserInfo){
		//对sysUser赋值
		sysUser.setUsrPassword("123456");
		sysUser.setUsrFlag(0); // 0 未登录
		
		//操作数据库
		int i = sysUserService.insert(sysUser);
		//System.out.println(i);
		int s=sysUserService.getMax();
		//System.out.println(s);
		
		//对sysUserInfo赋值
		String name=sysUser.getUsrName();
		sysUserInfo.setUserinfoName(name);
		sysUserInfo.setUserinfoUid(s);
		//sysUserInfo.setUserinfoId(1);
		//测试
//		System.out.println(sysUserInfo.getUserinfoUid());//id
//		System.out.println(sysUserInfo.getUserinfoName());//姓名
//		System.out.println(sysUserInfo.getUserinfoCard());//身份证
//		System.out.println(sysUserInfo.getUserinfoBirthday());//生日
//		System.out.println(sysUserInfo.getUserinfoNat());//民族
//		System.out.println(sysUserInfo.getUserinfoSex());//性别
//		System.out.println(sysUserInfo.getUserinfoAddress());//住址
        
		
		sysUserInfoService.insertSelective(sysUserInfo);

		return "";
	}
	
}
